/*
 * @Author: xiaosihan 
 * @Date: 2024-06-20 16:43:53 
 * @Last Modified by: xiaosihan
 * @Last Modified time: 2024-09-16 16:37:32
 */


import hashHistory from "@hashHistory";
import userStore from "@views/userStore";
import clsx from "clsx";
import { autorun } from "mobx";
import { ReactNode, useEffect, useRef, useState } from "react";
import { useLocation } from "react-router-dom";
import LoginBtn from "../component/LoginBtn/LoginBtn";
import styles from "./PCHeader.module.less";

interface Iprops {
    children?: ReactNode
}

// 公共头
export default function PCHeader() {

    const dom = useRef<HTMLDivElement | null>(null);
    const [data, setData] = useState({});
    const [isLogin, setIsLogin] = useState(userStore.isLogin);
    const loca = useLocation();

    useEffect(() => {

    }, [loca]);

    useEffect(() => autorun(() => {
        setIsLogin(userStore.isLogin);
    }), []);

    return (
        <div className={styles.PCHeaderBG} >
            <div className={styles.PCHeader} >

                <span className={styles.backHome} onClick={() => hashHistory.push("/")} >
                    <img src="./logo2.png" className={styles.logo} alt="" />
                </span>

                <div className={styles.right} >
                    {
                        isLogin &&
                        <>
                            <span
                                className={clsx(loca.pathname === "/fqrs" && styles.active, styles.btn)}
                                onClick={() => hashHistory.push("/fqrs")}
                            >报价请求</span>
                            <span
                                className={clsx(loca.pathname === "/inquiry" && styles.active, styles.btn)}
                                onClick={() => hashHistory.push("/inquiry")}
                            >询盘</span>
                            <span
                                className={clsx(loca.pathname === "/userOrder" && styles.active, styles.btn)}
                                onClick={() => hashHistory.push("/userOrder")}
                            >订单</span>
                            <span
                                className={clsx(loca.pathname === "/projectCollaboration" && styles.active, styles.btn)}
                                onClick={() => hashHistory.push("/projectCollaboration")}
                            >项目管理</span>
                        </>
                    }
                    {/* 登录按钮 */}
                    <LoginBtn />
                </div>

            </div>
        </div>
    );

}